package poker;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

import java.awt.event.*;

public class MyTabButton extends JPanel implements MouseListener {
	private JLabel name;
	private MyTabbedPanel mt;
	DefaultSettingsPanelGUI content;
	boolean isActive = false;
	public MyTabButton(String name, DefaultSettingsPanelGUI content, MyTabbedPanel mt)
	{
		this.content = content;
		this.mt = mt;
		this.name = new JLabel(name);
		setBackground(Color.WHITE);
		add(this.name);
		addMouseListener(this);
		setMaximumSize( new Dimension(90, 30) );
		setPreferredSize( new Dimension(90, 30) );
		setMinimumSize( new Dimension(90, 30) );
	}
	
	public void setActive(boolean a)
	{
		if(a)
		{
			setBackground(new Color(239, 247, 255));
			setBorder( new LineBorder(new Color(82,146,181) ) );
		} else {
			setBackground(Color.WHITE);
			setBorder(null);
		}
	}
	
	public String getName()
	{
		return name.getText();
	}
	
	public void mouseClicked(MouseEvent e) {
		mt.setContent(content, this);
		isActive = true;
		validate();
		mt.validate();
	}
	public void mouseEntered(MouseEvent e) {
		setBackground(new Color(239, 247, 255));
		setBorder( new LineBorder(new Color(82,146,181) ) );
	}
	public void mouseExited(MouseEvent e) {
		if(!isActive) {
			setBackground(Color.WHITE);
			setBorder(null);
		}
	}
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
